/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cc.altius.domain.mapper;

import cc.altius.model.*;
import java.math.BigDecimal;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.springframework.jdbc.core.RowMapper;

/**
 *
 * @author sagar
 */
public class HospitalRowMapper implements RowMapper<Hospital> {

    @Override
    public Hospital mapRow(ResultSet rs, int i) throws SQLException {
        System.out.println("inside HospitalRowMapper");
        Hospital hospital= new Hospital();
        hospital.setHospitalId(rs.getInt("HOSPITAL_ID"));
        hospital.setHospitalName(rs.getString("HOSPITAL_NAME"));
        hospital.setLevel(rs.getInt("LEVEL"));
        //hospital.getZoneId(rs.getInt(""));
        hospital.setBedDesc(rs.getString("BED_DESC"));
        hospital.setTieUpStage(rs.getInt("TIE_UP_STAGE"));
        hospital.setIpd(rs.getBigDecimal("IPD"));
        hospital.setOpd(rs.getBigDecimal("OPD"));
        hospital.setDayCare(rs.getBigDecimal("DAY_CARE"));
        hospital.setDiagnostics(rs.getBigDecimal("DIAGNOSTICS"));
//        hospital.setAmbulanceService(rs.getString("AMBULANCE_SERVICE"));
        hospital.setContact1(rs.getString("CONTACT_1"));
        hospital.setContact2(rs.getString("CONTACT_2"));
        hospital.setContact3(rs.getString("CONTACT_3"));
        hospital.setLatitude(rs.getDouble("LATITUDE"));
        hospital.setLongitude(rs.getDouble("LONGITUDE"));
        Zone zone = new Zone();
        zone.setZoneId(rs.getInt("ZONE_ID"));
        zone.setZoneName(rs.getString("ZONE_NAME"));
        zone.setZonePriority(rs.getInt("ZONE_PRIORITY"));
        MasterZone masterZone= new MasterZone();
        masterZone.setMasterZoneId(rs.getInt("MASTER_ZONE_ID"));
        masterZone.setMasterZoneCode(rs.getString("MASTER_ZONE_CODE"));
        City city= new City();
        city.setCityId(rs.getInt("CITY_ID"));
        city.setCityName(rs.getString("CITY_NAME"));
        State state= new State();
        state.setStateId(rs.getInt("STATE_ID"));
        state.setStateName(rs.getString("STATE_NAME"));
        city.setStateId(state);
        masterZone.setCityId(city);
        zone.setMasterZoneId(masterZone);
        hospital.setZoneId(zone);
        return hospital;
    }
    
}
